'''
Módulo base da estrutura de funções núcleo (Kernel) da simulação SPH
@author: hanniel
'''
from math import exp, sqrt, pi

class Gauss_Kernel:
    
    def __init__(self):
        
        pass
    
    def kernel(self, r,h):
        
        return((1.0/(h*sqrt(pi)))*exp(-r**2/h**2))
    
    def grad(self, r,h):
        
        pass
        
    def laplacian(self, r,h):
        
        pass
    
class Spline_Kernel:
    
    def __init__(self):
        
        pass
    
    def kernel(self, r,h):
        
        if r/h >1:
            
            return(0)
            
        if (1.0/2 < r/h) and (r/h<=1):
            
            return((8/(pi*h**3))*2*(1-r/h)**3)

        if (0<=r/h) and (r/h<=1.0/2):
            
            return((8/(pi*h**3))*(1.0-6*(r/h)**2+6*(r/h)**3))
        
    def grad(self, r,h):
        
        pass
        
    def laplacian(self, r,h):
        
        pass
        
class Poly6_Kernel:
    
    def __init__(self):
        
        pass
    
    def kernel(self, r,h):
        
        ra=abs(r)

        if (0<=ra) and (ra<=h):
            
            return((315/(64*pi*h**4))*(h**2-ra**2)**3)
        
        if (ra>h):
            
            return(0)
        
    def grad(self, r,h):
        
        ra=abs(r)

        if (0<=ra) and (ra<=h):
            
            return((-945/(32*pi*h**9))*r*(h**2-ra**2)**2)
        
        if (ra>h):
            
            return(0)
        
    def laplacian(self, r,h):
        
        ra=abs(r)

        if (0<=ra) and (ra<=h):
            
            return((-945/(32*pi*h**9))*(h**2-ra**2)*(3*h**2-7*ra**2))
        
        if (ra>h):
            
            return(0)
            
        